﻿using PARK.Common.Const;
using SqlSugar;
using System;
using Yitter.IdGenerator;

namespace PARK.CardAcct.Entitys
{
    /// <summary>
    /// 人员同步任务
    /// </summary>
    [SugarTable("consum_machine_employee")]
    [Tenant(ClaimConst.TENANT_ID)]
    public class MachineEmployeeEntity
    {
        /// <summary>
        /// 
        /// </summary>
        [SugarColumn(ColumnName = "taskId", IsPrimaryKey = true)]
        public string taskId { get; set; }
        /// <summary>
        /// 机器Id
        /// </summary>
        [SugarColumn(ColumnName = "MachineId")]
        public string MachineId { get; set; }
        /// <summary>
        /// 人员卡户Id
        /// </summary>
        [SugarColumn(ColumnName = "EmployeeId")]
        public string EmployeeId { get; set; }
        /// <summary>
        /// 公司Id
        /// </summary>
        [SugarColumn(ColumnName = "CompanyId")]
        public string CompanyId { get; set; }
        /// <summary>
        /// 公司名称
        /// </summary>
        [SugarColumn(ColumnName = "CompanyName")]
        public string CompanyName { get; set; }
        /// <summary>
        /// 事件类型 1新增 2编辑 -1删除
        /// </summary>
        [SugarColumn(ColumnName = "EvtType")]
        public int EvtType { get; set; }
        /// <summary>
        /// 任务时间
        /// </summary>
        [SugarColumn(ColumnName = "TaskDate")]
        public DateTime TaskDate { get; set; }
        /// <summary>
        /// 任务状态 0待执行 1执行成功
        /// </summary>
        [SugarColumn(ColumnName = "TaskStatus")]
        public int TaskStatus { get; set; }
        /// <summary>
        /// 同步完成时间
        /// </summary>
        [SugarColumn(ColumnName = "SynDate")]
        public DateTime? SynDate { get; set; }

        /// <summary>
        /// 创建
        /// </summary>
        public virtual void Create()
        {
            var userId = App.User.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
            var userName = App.User.FindFirst(ClaimConst.CLAINM_REALNAME)?.Value;
            this.taskId = YitIdHelper.NextId().ToString();
            this.TaskDate = DateTime.Now;
            this.TaskStatus = 0;
        }
    }
}